
import java.io.*;
import java.net.*;

public class UDPListener implements Runnable {
	
	int port;
	int bsize;
	
	public UDPListener(int port, int bsize){
		this.port = port;
		this.bsize = bsize;
	}

	@Override
	public void run() {
		
		byte[] buffer = new byte[bsize];
		
		//listen socket
		DatagramSocket ss = null;
		DatagramPacket in = new DatagramPacket(buffer, buffer.length);
		
		
		try {
			ss = new DatagramSocket(port);
			
			ss.receive(in);
			String data = new String(in.getData());
			
			System.out.println(data);
		
			ss.close();
			ss = null;
			return;
		} catch (IOException e) {
			e.printStackTrace();
		}
		
		
		
	}
}
